package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.domain.Trip;
import com.itheima.service.TripService;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestConstructor;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class App {
//**需求描述**：临近过年，公司需要统计员工过年的行程，现在需要在题目一的环境中对行程表进行功能维护，
// 项目中所使用的实体类、Service接口、Service实现类、Mapper接口以及单元测试类需要自行创建完成。
    @Autowired
    private TripService ts;
    @Test
    public void test01(){
        //1、查询行程表中所有的数据
        List<Trip> tripList = ts.queryAll();
        for (Trip trip : tripList) {
            System.out.println("trip = " + trip);
        }

    }
    @Test
    public void test02(){
        //2、添加用户过年的形成数据
        Trip trip = new Trip();

        trip.setUsername("蔡徐坤");
        trip.setGender(0);
        trip.setIdcard("12345678901234");
        trip.setFrom_address("中国深圳");
        trip.setTo_address("英国伦敦");
        trip.setStart_time("2022-11-21");
        ts.addTrip(trip);
        System.out.println("trip = " + trip);

    }
    @Test
    public void test03(){
        //3、根据ID查询用户的行程数据
        Trip trip1 = ts.queryById(1);
        System.out.println("trip1 = " + trip1);

    }
    @Test
    public void test04(){

        //4、根据ID修改用户的行程数据
        Trip trip2 = new Trip();
        trip2.setId(4);
        trip2.setUsername("芭芭拉");
        trip2.setGender(0);
        trip2.setIdcard("16734123485290");
        trip2.setFrom_address("中国上海");
        trip2.setTo_address("法国巴黎");
        trip2.setStart_time("2022-11-11");
        ts.updataByID(trip2);
        System.out.println("trip2 = " + trip2);
    }
    @Test
    public void test05(){
        //5、根据ID删除用户的行程数据
        ts.deteleById(7);
        //6、编写测试类,将测试结果打印至控制台。
    }

}
